﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="B2B.Models" %>


<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="main_content" runat="server">
  <div align="center" style="float:left" id="divDanhSach">
        <%
            foreach (var sanpham in (ArrayList)ViewData["listSP"])
            {
                string maSP = ((SP_DanhSachSanPham)sanpham).MaSanPham.ToString();
                string tenSP = ((SP_DanhSachSanPham)sanpham).TenSanPham.ToString();
                string hinhAnh = ((SP_DanhSachSanPham)sanpham).HinhAnh.ToString();
                string url = "../../Images/Alibaba/" + hinhAnh;
                string gia = ((SP_DanhSachSanPham)sanpham).Gia.ToString();
                string soLuongDatToiThieu = ((SP_DanhSachSanPham)sanpham).SoLuongDatToiThieu.ToString();
                string tenDVT = ((SP_DanhSachSanPham)sanpham).TenDVT.ToString(); 
          %>
            <div class="sanpham">
                <div style="height:5px"><a href="/Product/ProductDetail/<%=maSP %>"> <%=tenSP %> </a></div>
                <div style="height:200px; width:150px; padding-top:40px"><img src="<%=url %>"width="150px" height="150px"/></div>
                <div>Min oder: <%=soLuongDatToiThieu %><br /> FOB: <%=gia %> / <%=tenDVT %></div>
            </div>
            
          <%} %>

     
  </div>
    <!--Bo di cac khoang div-->
  <div class="clr"></div>
  <!--Ket61 thuc-->
  <!--Bắt đầu phân trang-->
  <div align="right">
      <div id="trigger-list">
      <%
          int tongpage =  int.Parse(ViewData["tongPage"].ToString());
          
          for(int i = 1; i <= tongpage; i++)
          {
      %>
          <input type="button"class="trigger error-trigger" value="<%=i %>" onclick="layDanhSachPhanTrang(<%=i %>)"/> 
      <%} %>
      </div>
  </div>
  <!--Kết thúc phân trang-->
 
    <script type="text/javascript">
        function layDanhSachPhanTrang(page) {
            var s = "";
            var oldPage = 0;
            $.getJSON("/Home/IndexPhanTrangJson?page=" + page,
                function (data) {
                    if (data.length > 0) {
                        for (i = 0; i < data.length; i++) {
                            s += "<div class='sanpham'>";
                            s += " <div style='height:5px'><a href='/Product/ProductDetail/" + data[i].MaSanPham + "'>" + data[i].TenSanPham + "</a></div>"
                            s += " <div style=' height:150px; width:150px; padding-top:40px'><img src='../../Images/Alibaba/" + data[i].HinhAnh + "'width='100px' height='350px'/></div>"
                            s += " <div>Min oder: " + data[i].SoLuongDatToiThieu+ "<br /> FOB: " + data[i].Gia + "/" + data[i].TenDVT+"</div>";
                            s += "</div>";
                        }
                        $("#divDanhSach").html(s);
                    } else
                        $("#divDanhSach").html("");
                });
            oldPage = page;
        }

      
    </script>

</asp:Content>

